<%@ include file="/WEB-INF/jsp/barNav.jsp"%>
<div class="container-fluid">
	<div class="row-fluid">
		<%@ include file="/WEB-INF/jsp/menu.jsp"%>


		<div class="span8">
		<c:set var="temps" value="0" scope="page" />

			<c:if test="${not empty lesParties}">
			<form action="rejoindre.html" method="post" id="formRejoindre">
				<table class="table table-hover">
					<thead>
						<tr>
							<th>#</th>
							<th>Nom de la partie</th>
							<th>Login usr 1</th>
							<th>Login usr 2</th>
							<th>Login usr 3</th>
							<th>Rejoindre?</th>
							<th>Timer</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${lesParties}" var="partie">
							<tr>
								<td><c:out value="${partie.id}" /></td>
								<td><c:out value="${partie.nom}" /></td>


								<c:forEach items="${partie.plateaux }" var="plateau">
									<c:if test="${partie.nbJoueurs == 1}">
										<td><c:out value="${plateau.joueur.login}" /></td>
										
									</c:if>
									<c:if test="${partie.nbJoueurs ==2 }">
										<td><c:out value="${plateau.joueur.login}" /></td>
									</c:if>
									<c:if test="${partie.nbJoueurs ==3 }">
										<td><c:out value="${plateau.joueur.login}" /></td>
									</c:if>


								</c:forEach>

								<c:if test="${partie.nbJoueurs == 3}">
									<td><button type="button" class="btn btn-danger"
											disabled="disabled">Complet</button></td>
									<td></td>
								</c:if>
								<c:if test="${partie.nbJoueurs == 1}">
									<td></td>
									<td></td>
									<td><button type="submit" name="idpartie" value="${partie.id}" class="btn btn-primary">Rejoindre</button></td>
									
								</c:if>
								<c:if test="${partie.nbJoueurs == 2}">
									<td></td>
									<td><button type="submit" name="idpartie" value="${partie.id}" class="btn btn-primary">Rejoindre</button></td>
									
								</c:if>
								
								<c:forEach items="${partie.plateaux }" var="plateau">
									<fmt:formatNumber var="time" value="${timers[partie.id] / 1000}" type="number" maxFractionDigits="0"/>										
											<%/*<td class="timerExpire" data-time="${time}">
												<c:out value="${time}"/>
											</td>*/ %>
											<c:set var="temps" value="${time}" scope="page" />
								</c:forEach>
								<td class="timerExpire" data-time="${time}">
												<c:out value="${temps}"/>
								</td>
							</tr>
						</c:forEach>
					</tbody>
				
				</table>
				</form>
			</c:if>
			<c:if test="${nbParties == 0}">
				<div class="clearfix">
					<br />
				</div>
				<div class="alert alert-error" data-nbParties="${nbParties}">
					Il n'y a aucune partie</div>
			</c:if>
		</div>
	</div>
</div>